#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include <QActionGroup>
#include <QTranslator>

#include "qextserialport.h"
#include "qextserialenumerator.h"


namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow {
    Q_OBJECT
public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected:
    void changeEvent(QEvent *e);

private:
    Ui::MainWindow *ui;
    QextSerialPort *portSerie;
    QextSerialEnumerator *serialEnum;

    QByteArray dataToSend; //stockage interne

    QActionGroup *languageActionGroup;
    QTranslator appTranslator;

    void log(QString str);

public slots:
    void cbxportChanged(int index);
    void cbxBaudrateChanged(int index);

    void on_actionA_propos_triggered(bool notUsed);
    void on_actionDebug_triggered(bool status);

    void on_pb_openClosePort_clicked(void);
    void on_pb_sendSerie_clicked(void);

    void storeData(QString str);
    void convHex(QString str);
    void convertDecToHex(QString str);

    void addln(void);

    void onDeviceDiscovered(const QextPortInfo &);
    void onDeviceRemoved(const QextPortInfo &);
    void onDataAvailable(void);

    void switchLanguage(QAction *action);
    void switchLanguage(QString locale);
};

#endif // MAINWINDOW_H
